﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using Matchingo.Common.Types.Enumerations;

namespace Matchingo.Modules.TitleScreenModule
{
	public partial class RotatingMenuButton : UserControl
	{
        private DirectionNames.Direction _arrowDirection;
        public DirectionNames.Direction ArrowDirection 
        {
            get { return _arrowDirection; }
            set
            {
                _arrowDirection = value;
                UpdateArrowDirection();
            }
        }

		public RotatingMenuButton()
		{
			// Required to initialize variables
			InitializeComponent();

            ArrowDirection = DirectionNames.Direction.Down;

            // hook up the events
            this.MouseEnter += new MouseEventHandler(RotatingMenuButton_MouseEnter);
            this.MouseLeave += new MouseEventHandler(RotatingMenuButton_MouseLeave);
            this.MouseLeftButtonDown += new MouseButtonEventHandler(RotatingMenuButton_MouseLeftButtonDown);
		}

        private void UpdateArrowDirection()
        {
            switch (ArrowDirection)
            {
                case DirectionNames.Direction.Up:
                    VisualStateManager.GoToState(this, "Up", true);
                    break;
                case DirectionNames.Direction.Left:
                    VisualStateManager.GoToState(this, "Left", true);
                    break;
                case DirectionNames.Direction.Down:
                    VisualStateManager.GoToState(this, "Down", true);
                    break;
                case DirectionNames.Direction.Right:
                    VisualStateManager.GoToState(this, "Right", true);
                    break;
            }
        }

        void RotatingMenuButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            VisualStateManager.GoToState(this, "MouseDown", true);
        }

        void RotatingMenuButton_MouseEnter(object sender, MouseEventArgs e)
        {
            VisualStateManager.GoToState(this, "MouseOver", true);
        }

        void RotatingMenuButton_MouseLeave(object sender, MouseEventArgs e)
        {
            VisualStateManager.GoToState(this, "MouseOut", true);
        }

	}
}